import 'package:flutter/material.dart';
import 'package:get/get.dart';

class OrderListController extends GetxController
    with GetSingleTickerProviderStateMixin {
  late TabController tabController;
  var tabLists = [].obs;
  @override
  void onInit() {
    super.onInit();
    getTabBarData();
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {
    super.onClose();
  }

  Future<List<Map<String, dynamic>>> tabBarTitles() {
    List<Map<String, dynamic>> list = [
      {"id": 1, "title": "全部"},
      {"id": 2, "title": "待付款"},
      {"id": 3, "title": "待收货"},
      {"id": 4, "title": "已收货"},
      {"id": 5, "title": "已取消"}
    ];
    return Future.value(list);
  }

  getTabBarData() async {
    List list = await tabBarTitles();
    tabController = TabController(length: list.length, vsync: this);
    tabLists.value = list;
    tabController.addListener(() {
      if (tabController.animation!.value == tabController.index) {
        print(tabController.index);
      }
    });
  }
}
